<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
  <link href="https://cdn.bootcdn.net/ajax/libs/amazeui/2.7.2/css/amazeui.min.css" rel="stylesheet">
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
</head>
<body>
    
    <form class="am-form" method="POST" action="./task/add">
        <fieldset>
          <legend>添加预约任务 丐版</legend>

          
      
          <div class="am-form-group">
            <label for="doc-ta-1">账号列表 英文逗号分隔</label>
            <textarea name="usernames" id="usernames" class="" rows="5" placeholder="例：19118001055,19118001055"></textarea>
          </div>

          <div class="am-form-group">
            <label for="doc-ta-1">密码列表 英文逗号分隔 顺序与账号列表对应</label>
            <textarea name="passwords" id="passwords" class="" rows="5" placeholder="例：19118001055,19118001055"></textarea>
          </div>

          <div class="am-form-group">
            <label for="doc-ipt-email-1">预约日期 仅单次预约时生效</label>
            <input name="date" id="date" type="text" class="" placeholder="例：2020-09-12">
          </div>

          <div class="am-form-group">
            <label for="doc-ipt-email-1">开始时间</label>
            <input name="starTime" id="starTime" type="text" class="" placeholder="例：08:30">
          </div>

          <div class="am-form-group">
            <label for="doc-ipt-email-1">结束时间</label>
            <input name="endTime" id="endTime" type="text" class="" placeholder="例：22:00">
          </div>
          

          <div class="am-form-group">
            <label for="doc-ipt-pwd-1">任务类型</label>
            <div class="am-radio">
                <label>
                  <input type="radio" name="type" value="1" checked>
                  单次预约
                </label>
              </div>
          
              <div class="am-radio">
                <label>
                  <input type="radio" name="type" value="2">
                  每日任务
                </label>
              </div>

              <div class="am-radio">
                <label>
                  <input type="radio" name="type" value="3">
                  每周循环
                </label>
              </div>

              <div class="am-radio">
                <label>
                  <input type="radio" name="type" value="4">
                  每月循环
                </label>
              </div>
          </div>

          <div class="am-form-group">
            <label for="doc-ta-1">重复信息 英文逗号分隔</label>
            <textarea name="repeatInfo" class="" rows="5" placeholder="例：1,4,5,6（代表 每周一、四、五、六 或 每月1、4、5、6日）"></textarea>
          </div>

          <div class="am-form-group">
            <label for="doc-ta-1">候选座位id列表 英文逗号分隔</label>
            <textarea name="seatNums" class="" rows="5" placeholder="例：824,825,826,827（是人数的整倍数）"></textarea>
          </div>

          <div class="am-form-group">
            <label for="doc-ta-1">接收消息的邮箱列表 英文逗号分隔 顺序与账号列表对应</label>
            <textarea name="emails" class="" rows="5" placeholder="例：110@qq.com,112@qq.com"></textarea>
          </div>

          
          <p><button type="button" class="am-btn am-btn-default" onclick="sub()">提交</button></p>
        </fieldset>
      </form>


    <script>

      function sub() {
        let content = {
          // "type": $("input[name='type']:checked").val(),
          "repeatInfo": $('textarea[name="repeatInfo"]').val(),
          "date": $('input[name="date"]').val(),
          "starTime": $('input[name="starTime"]').val(),
          "endTime": $('input[name="endTime"]').val(),
          "usernames": $('textarea[name="usernames"]').val(),
          "passwords": $('textarea[name="passwords"]').val(),
          "seatNums": $('textarea[name="seatNums"]').val(),
          // "weight": parseInt($('input[name="weight"]').val()),
          "emails": $('textarea[name="emails"]').val()
        };

        console.log(content);

        $.ajax({
          type: "POST",
          url: "./task/add",
          contentType: "application/json;charset=utf-8",
          data: content,
          dataType: "json",
          success:function (message) {
            alert("提交成功"+JSON.stringify(message));
          },
          error:function (message) {
            alert("提交失败"+JSON.stringify(message));
          }
        });
      }


    </script>

</body>
</html>